// pages/my/mytravel/mytravel.js
var api = require('../../../utils/utils.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    travel: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.getStorage({
      key: 'userInfo',
      success: jack => {
        console.log(jack);
        if (jack.data == null) {
          wx.navigateBack({
            delta: 1,
            complete: (res) => {
              wx.setStorage({
                data: this.data.message,
                key: 'message',
              })
            }
          })
        }
      },
      fail: err => {
        wx.navigateBack({
          delta: 1,
          complete: (res) => {
            wx.setStorage({
              data: this.data.message,
              key: 'message',
            })
          }
        })
      },
    })

    var that = this;
    api.getTriplist(function (travel) {
      that.setData({
        travel: travel.result.page
      })
      console.log(travel)
    })
    api.getTriplist(function (rows) {
      that.setData({
        rows: rows.result.page.rows
      })
      console.log(rows);
    })

    console.log(that.data.user)


  },

  toDetails: function (e) {
    var id = e.currentTarget.dataset.id;
    console.log(id);
    wx.navigateTo({
      url: 'travell-details/travell-details?id=' + id,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})